#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

dir=$(cd `dirname $0`;pwd)
echo "$@"
echo "$dir"
function build()
{
  echo "begin make"
  type="$1"
  shift 1
  for path in $@
  do
     echo "make $path..." && "$dir/$path/build.sh" "$type" && echo "make $path finish"
  done
  echo "end make"
}

type=" "
if [ $# == 0 ]; then
 type='-D'
elif [ $# == 1 -a $1 == "debug" ]; then
 type='-D' 
elif [ $# -eq 1 -a $1 == "release" ]; then
  type='-R' 
elif [ $# == 1 -a $1 == "clean" ]; then
  type='-C'
else 
 echo "invaild parameter!";exit 0
fi

build "$type" CollectKlineData CollectSSHQData  CollectChipData CollectSSHQData_Publish


echo $?
